
<p>条件判断不应该总是评估为<code> TRUE </code>或<code> FALSE </code></p>

<h2>不规范的代码示例</h2>

<pre>
//在同一表达式中foo不能等于和不等于bar
if(foo == bar && something && foo != bar) {...}
</pre>
<pre>
private void compute(int foo) {
  if (foo == 4) {
    doSomething();
    // 我们知道foo此时等于4，因此下一个条件始终为false
    if (foo > 4) {...}
    ...
  }
  ...
}
</pre>
<pre>
private void compute(boolean foo) {
  if (foo) {
    return;
  }
  doSomething();
  // foo is always false here
  if (foo){...}
  ...
}
</pre>

<h2>更多</h2>
<ul>
  <li><a href="http://cwe.mitre.org/data/definitions/489">MITRE, CWE-489</a> - Leftover Debug Code</li>
  <li><a href="http://cwe.mitre.org/data/definitions/570">MITRE, CWE-570</a> - Expression is Always False</li>
  <li><a href="http://cwe.mitre.org/data/definitions/571">MITRE, CWE-571</a> - Expression is Always True</li>
  <li>MISRA C:2004, 13.7 - Boolean operations whose results are invariant shall not be permitted.</li>
  <li>MISRA C:2012, 14.3 - Controlling expressions shall not be invariant</li>
</ul>
